package com.example.demo.controller;

import com.example.demo.common.domain.Employee;
import com.example.demo.common.domain.LeaveRecordPlus;
import com.example.demo.common.domain.Leave_Record;
import com.example.demo.common.util.Result;
import com.example.demo.common.util.Singleton;
import com.example.demo.service.EmployeeService;
import com.example.demo.service.LeaveService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@Controller
public class LinkController {
    private Singleton singleton;
    @Autowired
    @Qualifier("es")
    private EmployeeService employeeService;
    @Autowired
    @Qualifier("leaveServiceImpl")
    LeaveService leaveService;







    @RequestMapping("/logout")
    public String logout(HttpSession session,Model model){
        session.setMaxInactiveInterval(0);
        return "login";
    }


    @RequestMapping("/")
    public String index(){
        return "login";
    }

    @RequestMapping("/check")
    @ResponseBody
    public Map login(HttpSession session,int eid,String mpwd){

        Employee find = employeeService.selectByPrimaryKey(eid);
        if(find != null && find.getEpassword().equals(mpwd)){
            session.setAttribute("employee",find);

            return Result.success(true);
        }
        return Result.success(false);
    }










    @RequestMapping("/list")
    public String list(HttpSession session,Model model){
        return "leavelist";
    }

    @RequestMapping("/financial")
    public String financial(){
        return "financial/callist";
    }




}
